import os
import shutil

from short_file_plicing import main
from utils.file_io import file_r, file_w

if __name__ == '__main__':
    # main()
    num = 1
    sound_root_path = "wav"
    transcript_root_path = "transcript"
    new_transcript_path = transcript_root_path + "/" + "transcript_new.txt"
    transcript_text = file_r(transcript_root_path + "/transcript.txt")
    if not os.path.exists(sound_root_path+"/output_rename/"):
        os.mkdir(sound_root_path+"/output_rename/")
    for text_line in transcript_text.split("\n"):
        file_txt = "".join(text_line.split(" ")[1:])
        if len(file_txt) == 0:
            continue
        file_name = str(num)
        new_line = str(num) + " " + file_txt + "\n"
        file_w(new_transcript_path, new_line, "a")
        shutil.copy(sound_root_path + "/output/" + text_line.split(" ")[0] + ".wav",sound_root_path + "/output_rename/" + file_name + ".wav")
        num += 1




